package cn.boy.gui.adminstrator;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import cn.boy.domain.Adminstrator;
import cn.boy.home.HomeApplication;
import cn.boy.home.R;

public class AdminInfoActivity extends Activity {
	
	TextView txtNO;
	TextView txtName;
	TextView txtAge;
	TextView txtSex;
	TextView txtdepart;
	
	Button editButton;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.admin_info);
		
		findVies();
		
		initInfo();
		
		editButton.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				Intent intent = new Intent(AdminInfoActivity.this,AdminInfoEditActivity.class);
				startActivity(intent);
				finish();
				
			}
		});
	}

	private void initInfo() {

		HomeApplication app = (HomeApplication) getApplicationContext();
		Adminstrator admin = app.getAdmin();
		
		
		txtNO.setText(admin.getNO());
		txtName.setText(admin.getName());
		txtAge.setText(admin.getAge());
		txtSex.setText(admin.getSex());
		txtdepart.setText(admin.getDepartment());
		
	}

	private void findVies() {
		txtNO = (TextView)findViewById(R.id.tv_admin_no);
		txtName = (TextView)findViewById(R.id.tv_admin_name);
		txtAge = (TextView)findViewById(R.id.tv_admin_age);
		txtSex = (TextView)findViewById(R.id.tv_admin_sex);
		txtdepart = (TextView)findViewById(R.id.tv_admin_depart);
		
		editButton = (Button)findViewById(R.id.btn_edit);
		
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		return super.onCreateOptionsMenu(menu);
	}
	
	@Override
	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		return super.onMenuItemSelected(featureId, item);
	}
	
	
}
